define(['api'], function (api) {
    // model
    var staffModel = {
        StaffId: '',
        StaffNo: '',
        Name: '',
        BelongToId: '',
        BelongToName: '',
        Salary: '',
        CreatedTime: '',
        OwnSocialInsurance: '',
        Enabled: false,
        CompanyId: '',
        PositionId: '',
        PositionName: '',
        Leader: '',
        StaffTypeName: '',
        StaffTypeValue: '',
        Phone: '',
        PermissionName: '',
        PermissionId: '',
        JobLevelId: '',
        SkillLevelId: '',
        PerformanceSalary: '',
        OwnProvidentFund: '',
        CompanySocialInsurance: '',
        CompanyProvidentFund: '',
        ParentalAllowance: '',
        MealSupplement: '',
        WorkShiftId: '',
        EntryTime: '',
        PermanentDate: '',
        Sex: '',
        Birthday: '',
        NativePlace: '',
        ResidenceAddress: '',
        IdCard: '',
        ExpiredDate: '',
        CulturalLevel: '',
        Profession: '',
        BankName: '',
        BankCard: '',
        isRenewed: false,
        ContractStartTime: '',
        ContractEndTime: '',
        userState: '',
        Remarks: '',
        isManage: false,
        Password: ''
    };

    var StaffModal = {
        name: 'staff-modal',
        template: ' <div class="c-two-top">' +
        '        <!--弹框遮罩 可编辑员工资料-->' +
        '        <div class="list-details"  v-show="showModal">' +
        '            <!--信息弹框盒子-->' +
        '            <div class="message-box draggable">' +
        '                <!--切换-->' +
        '                <div class="addNewStaffBox clearfix">' +
        '               <col class="staff-spin-col" span="8">' +
        '                 <spin v-if="saveLoading" size="large" fix>' +
        '                  <icon type="load-c" size=18 class="save-staff-loading"></icon>' +
        '                   <div>保存中...</div>' +
        '                 </spin>' +
        '               </col>' +
        '                    <div class="leftInfo">' +
        '                        <div class="personal_img">' +
        '                            <div class="con4">' +
        '                                <canvas id="cvs" width="200" height="120"></canvas>' +
        '                                <span class="btn upload">上传个人头像<input type="file" class="upload_pic"' +
        '                                                                      id="upload"/></span>' +
        '                            </div>' +
        '                        </div>' +
        '                        <div class="Employee_information Employee_informationone">' +
        '                            <i-Select v-model="fromModal" size="small" placeholder="所属公司">' +
        '                                <i-Option v-for="item in staffFromList" :value="item.value" :key="item">{{ item.label }}' +
        '                                </i-Option>' +
        '                            </i-Select>' +
        '                        </div>' +
        '                        <div class="leftStaffInfo-footer">' +
        '                            <Button type="primary" @click="modifyaccountpassword = true">修改账户密码</Button>' +
        '                            <Modal' +
        '                                    title="修改账户密码"' +
        '                                    v-model="modifyaccountpassword"' +
        '                                    width="360"' +
        '                                    :mask-closable="false"' +
        '                                    ok-text="保存修改"' +
        '                                    cancel-text="忘记密码"' +
        '                                    class-name="password-one vertical-center-modal">' +
        '                                <div class="password-ul">' +
        '                                    <div class="password-new">' +
        '                                        <div class="newpassword"><span>原密码</span></div>' +
        '                                        <input type="text">' +
        '                                    </div>' +
        '                                    <div class="password-old">' +
        '                                        <div class="oldpassword"><span>新密码</span></div>' +
        '                                        <input type="text">' +
        '                                    </div>' +
        '                                    <div class="password-confirm">' +
        '                                        <div class="confirmnewpassword"><span>确认新密码</span></div>' +
        '                                        <input type="text">' +
        '                                    </div>' +
        '                                </div>' +
        '                                <div class="wjmmbox">' +
        '                                    <dd type="primary" @click="wangjimima = true">忘记密码</dd>' +
        '                                    <Modal' +
        '                                            title="忘记密码"' +
        '                                            v-model="wangjimima"' +
        '                                            width="360"' +
        '                                            :mask-closable="false"' +
        '                                            ok-text="保存"' +
        '                                            cancel-text="取消"' +
        '                                            class-name="vertical-center-modal password-tow">' +
        '                                        <div class="password-ul">' +
        '                                            <div class="password-newone">' +
        '                                                <div class="newpassword"><span>手机号</span></div>' +
        '                                                <input type="text">' +
        '                                            </div>' +
        '                                            <div class="password-old">' +
        '                                                <div class="oldpassword"><span>验证码</span></div>' +
        '                                                <input type="text">' +
        '                                            </div>' +
        '                                            <div class="password-confirm">' +
        '                                                <div class="confirmnewpassword"><span>输入新密码</span></div>' +
        '                                                <input type="text">' +
        '                                            </div>' +
        '                                        </div>' +
        '                                        <div class="hqyzm">' +
        '                                            <p>获取验证码</p>' +
        '                                        </div>' +
        '                                    </Modal>' +
        '                                </div>' +
        '                            </Modal>' +
        '                        </div>' +
        '                        <div class="bind-mobile">' +
        '                            <Button type="primary" @click="bindmobile = true">绑定手机</Button>' +
        '                            <Modal' +
        '                                    title="绑定手机"' +
        '                                    v-model="bindmobile"' +
        '                                    width="360"' +
        '                                    :mask-closable="false"' +
        '                                    ok-text="保存"' +
        '                                    cancel-text="取消"' +
        '                                    class-name="vertical-center-modal password-one password-there">' +
        '                                <div class="password-ul">' +
        '                                    <div class="password-newone">' +
        '                                        <div class="newpassword"><span>手机号</span></div>' +
        '                                        <input type="text">' +
        '                                    </div>' +
        '                                    <div class="password-confirm">' +
        '                                        <div class="confirmnewpassword"><span>验证码</span></div>' +
        '                                        <input type="text">' +
        '                                    </div>' +
        '                                    <div class="hqyzm">' +
        '                                        <p>获取验证码</p>' +
        '                                    </div>' +
        '                                </div>' +
        '                            </Modal>' +
        '                        </div>' +
        '                        <div class="bind-weChat">' +
        '                            <Button type="primary" @click="bindwechat = true">绑定微信</Button>' +
        '                            <Modal' +
        '                                    title="绑定微信"' +
        '                                    v-model="bindwechat"' +
        '                                    width="360"' +
        '                                    :mask-closable="false"' +
        '                                    ok-text=""' +
        '                                    cancel-text=""' +
        '                                    class-name="vertical-center-modal password-one password-four">' +
        '                                <div slot="footer">' +
        '                                </div>' +
        '                                <div class="bindwechat-ul">' +
        '                                    <div class="bdwx-ewm"></div>' +
        '                                    <p>使用微信扫描二维码绑定微信</p>' +
        '                                </div>' +
        '                            </Modal>' +
        '                        </div>' +
        '                    </div>' +
        '                    <div class="Employeeinformation Roster" style="margin-top: 0px">' +
        '                        <div class="rightInfo-tab01">' +
        '                            <div class="close">' +
        '                                <a href="javascript:;" class="clickClose" @click="hideEditStaff"></a>' +
        '                            </div>' +
        '                            <Tabs value="name1" :animated="false">' +
        '                                <Tab-pane label="员工资料" name="name1">' +
        '                                    <div class="Sales_return_record">' +
        '                                        <div class="Sales_return_insert">' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>姓名</strong>' +
        '                                            </div>' +
        '                                            <input type="text" v-model="currentModalData.Name">' +
        '                                            <div class="Employee_form">' +
        '                                               <i class="mustStars"></i>' +
        '                                                <strong>档案号</strong>' +
        '                                            </div>' +
        '                                            <input v-model="currentModalData.StaffNo"' +
        '                                                           class="border-right" style="width: 33.338%;border-right: 1px solid #EAEEEF;" disabled></input>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>手机号码</strong>' +
        '                                            </div>' +
        '                                            <input type="text" v-model="currentModalData.Phone">' +
        '                                            <div class="Employee_form">' +
        '                                                <strong>账号状态</strong>' +
        '                                            </div>' +
        '                                            <i-Select class="border-right" style="width: 33.338%;" placeholder="" v-model="currentModalData.userState">' +
        '                                                <i-Option v-for="item in userStateOps" :value="item.value"' +
        '                                                          :key="value">{{ item.label }}' +
        '                                                </i-Option>' +
        '                                            </i-Select>' +
        '                                            <div class="Employee_form">' +
        '                                                <strong>密码</strong>' +
        '                                            </div>' +
        '                                            <input type="text" placeholder="不修改密码则为空"' +
        '                                                   v-model="currentModalData.Password">' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>类型</strong>' +
        '                                            </div>' +
        '                                            <i-Select class="border-right" style="width: 33.338%;" placeholder="" v-model="currentModalData.StaffTypeValue">' +
        '                                                <i-Option v-for="item in staffTypes" :value="item.value"' +
        '                                                          :key="value">{{ item.label }}' +
        '                                                </i-Option>' +
        '                                            </i-Select>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>部门</strong>' +
        '                                            </div>' +
        '                                            <div style="width: 33%;overflow: hidden;float: left">' +
        '                                                <cascader :data="secList" v-model="currentModalData.BelongToId"></cascader>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>管理岗</strong>' +
        '                                            </div>' +
        '                                            <div class="Administration">' +
        '                                                <Radio-group class="border-right" v-model="currentModalData.isManage" vertical>' +
        '                                                    <Radio :label="true">' +
        '                                                        <span>是</span>' +
        '                                                    </Radio>' +
        '                                                    <Radio :label="false">' +
        '                                                        <span>否</span>' +
        '                                                    </Radio>' +
        '                                                </Radio-group>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>职位</strong>' +
        '                                            </div>' +
        '                                            <div style="float:left;width: 33%;">' +
        '                                                <i-Select v-model="currentModalData.PositionId" style="width: 100%;"' +
        '                                                          placeholder="">' +
        '                                                    <i-Option v-for="item in postList" :value="item.PositionId"' +
        '                                                              :key="currentModalData.PositionName">{{ item.PositionId }}' +
        '                                                    </i-Option>' +
        '                                                </i-Select>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>角色</strong>' +
        '                                            </div>' +
        '                                            <i-Select class="border-right" v-model="currentModalData.PermissionName" style="width:33.338%"' +
        '                                                      placeholder="" disabled>' +
        '                                            </i-Select>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>职称等级</strong>' +
        '                                            </div>' +
        '                                            <div style="float:left;width: 33%;">' +
        '                                                <i-Select v-model="currentModalData.jobLevel" style="width:100%"' +
        '                                                          placeholder="" disabled>' +
        '                                                </i-Select>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>技术等级</strong>' +
        '                                            </div>' +
        '                                            <div style="float:left;width: 33.338%;">' +
        '                                                <i-Select class="border-right" v-model="currentModalData.skillLevel" style="width:100%"' +
        '                                                          placeholder="" disabled>' +
        '                                                </i-Select>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>薪资</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum" style="width: 33%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.Salary"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>绩效薪资</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum border-right" style="width: 33.338%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.PerformanceSalary"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>公积金(个人)</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum" style="width: 33%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.OwnProvidentFund"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>社保(公司)</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum border-right" style="width: 33.338%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.CompanySocialInsurance"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>公积金(公司)</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum" style="width: 33%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.CompanyProvidentFund"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>社保(个人)</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum border-right" style="width: 33.338%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.OwnSocialInsurance"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>父母津贴</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum" style="width: 33%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.ParentalAllowance"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form">' +
        '                                                <strong>餐补</strong>' +
        '                                            </div>' +
        '                                            <div class="inputNum border-right" style="width: 33.338%;">' +
        '                                                <Input-number :max="90000000" :min="-1000000"' +
        '                                                              v-model="currentModalData.MealSupplement"' +
        '                                                              :step="100"></Input-number>' +
        '                                            </div>' +
        '                                            <div class="Employee_form" style="border-bottom: 1px solid #EAEEEF;height: 29px;">' +
        '                                                <i class="mustStars"></i>' +
        '                                                <strong>上班班次</strong>' +
        '                                            </div>' +
        '                                            <div class="workWidth">' +
        '                                                <i-Select v-model="currentModalData.WorkShiftId" placeholder="" disabled>' +
        '                                                </i-Select>' +
        '                                            </div>' +
        '                                        </div>' +
        '                                    </div>' +
        '                                </Tab-pane>' +
        '                                <div class="huamingce">' +
        '                                    <Tab-pane label="花名册" name="name2">' +
        '                                        <div class="Sales_return_record">' +
        '                                            <div class="Sales_return_insert2">' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>入职时间</strong>' +
        '                                                </div>' +
        '                                                <div class="Inductiontime border-none" style="float:left;width: 33%;">' +
        '                                                    <Row>' +
        '                                                        <Col span="12">' +
        '                                                        <Date-picker v-model="currentModalData.EntryTime" type="date" placeholder=""' +
        '                                                                     placement="bottom-end"></Date-picker>' +
        '                                                        </Col>' +
        '                                                    </Row>' +
        '                                                </div>' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>转正日期</strong>' +
        '                                                </div>' +
        '                                                <div class="Inductiontime" style="float:left;width: 33.338%;">' +
        '                                                    <Row>' +
        '                                                        <Col span="12">' +
        '                                                        <Date-picker v-model="currentModalData.PermanentDate" type="date" placeholder=""' +
        '                                                                      placement="bottom-end"></Date-picker>' +
        '                                                        </Col>' +
        '                                                    </Row>' +
        '                                                </div>' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>性别</strong>' +
        '                                                </div>' +
        '                                                <i-Select v-model="currentModalData.Sex" style="width: 33%; float:left;"' +
        '                                                          placeholder="">' +
        '                                                    <i-Option v-for="item in sexOps" :value="item.value" :key="item">' +
        '                                                        {{' +
        '                                                        item.label }}' +
        '                                                    </i-Option>' +
        '                                                </i-Select>' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>生日日期</strong>' +
        '                                                </div>' +
        '                                                <div class="Inductiontime" style="float:left;width: 33.338%;">' +
        '                                                    <Row>' +
        '                                                        <Col span="12">' +
        '                                                        <Date-picker v-model="currentModalData.Birthday" type="date" placeholder=""' +
        '                                                                      placement="bottom-end"></Date-picker>' +
        '                                                        </Col>' +
        '                                                    </Row>' +
        '                                                </div>' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>籍贯</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.NativePlace" type="text">' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>户籍地址</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.ResidenceAddress" type="text" style="border-right: 1px solid #EAEEEF;width: 33.338%;">' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>身份证</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.IdCard" type="text">' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>过期日期</strong>' +
        '                                                </div>' +
        '                                                <div class="Inductiontime" style="float:left;width: 33.338%;">' +
        '                                                    <Row>' +
        '                                                        <Col span="12">' +
        '                                                        <Date-picker v-model="currentModalData.ExpiredDate" type="date" placeholder=""' +
        '                                                                     placement="bottom-end"></Date-picker>' +
        '                                                        </Col>' +
        '                                                    </Row>' +
        '                                                </div>' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>文化程度</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.CulturalLevel" type="text">' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>专业</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.Profession" type="text" style="border-right: 1px solid #EAEEEF;width: 33.338%;">' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>银行开户行</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.BankName" type="text">' +
        '                                                <div class="Employee_form01">' +
        '                                                    <strong>银行卡号</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.BankCard" type="text" style="border-right: 1px solid #EAEEEF;width: 33.338%;">' +
        '                                                <div class="Employee_form01" style="border-bottom: 1px solid #EAEEEF;">' +
        '                                                    <strong>备注</strong>' +
        '                                                </div>' +
        '                                                <input v-model="currentModalData.Remarks" type="text" class="inputLong">' +
        '                                                <div class="Employee_form02">' +
        '                                                    <strong>合同开始时间</strong>' +
        '                                                </div>' +
        '                                                <div class="Employee_form02">' +
        '                                                    <strong>合同结束时间</strong>' +
        '                                                </div>' +
        '                                                <div class="Employee_form03" style="border-right: none">' +
        '                                                    <strong>续签</strong>' +
        '                                                </div>' +
        '                                                <div class="Employee_form03" style="border-right: 1px solid #EAEEEF;">' +
        '                                                    <strong>操作</strong>' +
        '                                                </div>' +
        '                                                <div class="Inductiontime01 time-s-e">' +
        '                                                    <Row>' +
        '                                                        <Col span="12">' +
        '                                                        <Date-picker v-model="currentModalData.ContractStartTime" type="date" placeholder=""' +
        '                                                                      placement="bottom-end"></Date-picker>' +
        '                                                        </Col>' +
        '                                                    </Row>' +
        '                                                </div>' +
        '                                                <div class="Inductiontime01 time-s-e">' +
        '                                                    <Row>' +
        '                                                        <Col span="12">' +
        '                                                        <Date-picker v-model="currentModalData.ContractEndTime" type="date" placeholder=""' +
        '                                                                      placement="bottom-end"></Date-picker>' +
        '                                                        </Col>' +
        '                                                    </Row>' +
        '                                                </div>' +
        '                                                <div class="Employee_form04" style="border-right: none">' +
        '                                                    <Checkbox v-model="currentModalData.isRenewed" label=""></Checkbox>' +
        '                                                </div>' +
        '                                                <div class="Employee_form04">' +
        '                                                    <div class="Employee_form04_img01">' +
        '                                                    </div>' +
        '                                                    <div class="Employee_form04_img02">' +
        '                                                    </div>' +
        '                                                </div>' +
        '                                            </div>' +
        '                                        </div>' +
        '                                    </Tab-pane>' +
        '                                </div>' +
        '                            </Tabs>' +
        '                            <!-- 底部按钮-->' +
        '                            <div class="staffBtn">' +
        '                                <button class="s-cancel" @click="hideEditStaff"><i></i>取消</button>' +
        '                                <button class="s-save" @click="handleSaveStaffData"><i></i>保存</button>' +
        '                            </div>' +
        '                        </div>' +
        '                    </div>' +
        '                </div>' +
        '                <div class="details-but">' +
        '                    <div class="details-but-left"></div>' +
        '                    <a href="#" class="shuaxin"></a>' +
        '                    <div class="details-but-right"></div>' +
        '                </div>' +
        '            </div>' +
        '            <div class="zhezhao" :class="{ \'show-mask\': showMask }" @click="hideEditStaff"></div>' +
        '        </div>' +
        '        <dl>' +
        '            <dd type="primary" class="addNewStaffModal" @click="handleNewStaff"><i></i>添加新员工</dd>' +
        '            <dd type="primary" @click="alterInfoModal = true" class="alterInfoModal"><i></i>批量修改信息</dd>' +
        '            <Modal' +
        '                    title="批量修改资料"' +
        '                    v-model="alterInfoModal"' +
        '                    :mask-closable="false"' +
        '                    width="475"' +
        '                    ok-text="确认"' +
        '                    on-cancel="取消"' +
        '                    @on-ok="handleSave"' +
        '                    @on-cancel="handleCancel"' +
        '                    class-name="vertical-center-modal alterInfoWrap">' +
        '                <div class="alterInfoBox">' +
        '                    <div class="shebao_box">' +
        '                        <i-Select v-model="socialSecurityType">' +
        '                            <!--选择框-->' +
        '                            <i-Option v-for="item in socialSecurityArr" :value="item.value" :key="item">{{ item.label }}' +
        '                            </i-Option>' +
        '                        </i-Select>' +
        '                    </div>' +
        '                    <div class="inputNum-shebao">' +
        '                        <div class="shebao_money">' +
        '                            <strong>社保金额</strong>' +
        '                        </div>' +
        '                        <!--社保金额修改输入框-->' +
        '                        <Input-number :max="90000000" :min="-1000000" :disabled="disabled" v-model="socialSecurityNum"></Input-number>' +
        '                        <Button type="primary" @click="handleSetSafe">修改</Button>' +
        '                    </div>' +
        '                    <div class="table_shebao">' +
        '                        <i-Table border :columns="socialSecurityCol" :data="userTempArr" @on-select="handleSelectRow"' +
        '                                 @on-selection-change="handleSelectRow"></i-Table>' +
        '                    </div>' +
        '                </div>' +
        '            </Modal>' +
        '            <dd type="primary" @click="moveStaffModal = true" class="moveStaffModal"><i></i>移动人员</dd>' +
        '            <Modal' +
        '                    title="转移员工"' +
        '                    v-model="moveStaffModal"' +
        '                    width="340"' +
        '                    ok-text="确认"' +
        '                    on-cancel="取消"' +
        '                    :mask-closable="false"' +
        '                    class-name="vertical-center-modal moveStaffWrap">' +
        '                <div class="modal-content">' +
        '                    <ul class="pri-ul">' +
        '                        <li class="pri-li">' +
        '                            <span class="model-left removeLeft">待转移人员</span>' +
        '                            <p class="model-right remove-right">' +
        '                                <Checkbox v-model="staffChecked">张三</Checkbox>' +
        '                            </p>' +
        '                        </li>' +
        '                        <li class="pri-li">' +
        '                            <span class="model-left removeLeft">转移至</span>' +
        '                            <p class="model-right remove-right">' +
        '                                <i-select v-model="transferTo" style="width:100%" placeholder="">' +
        '                                </i-select>' +
        '                            </p>' +
        '                        </li>' +
        '                        <li class="pri-li">' +
        '                            <span class="model-left removeLeft">连同组员移动</span>' +
        '                            <p class="model-right remove-right">' +
        '                                <Radio-group v-model="moveRadio">' +
        '                                    <Radio label="是"></Radio>' +
        '                                    <Radio label="否"></Radio>' +
        '                                </Radio-group>' +
        '                            </p>' +
        '                        </li>' +
        '                    </ul>' +
        '                </div>' +
        '            </Modal>' +
        '            <dd type="primary" size="large" @click="exportData" class="export"><i></i>导出Excel</dd>' +
        '        </dl>' +
        '        <div class="giveLimits">授权上限：50/99</div>' +
        '        <div class="c-sort">' +
        '            <strong class="state-input">' +
        '                <i-select v-model="defaultSort" placeholder="默认排序">' +
        '                    <i-option v-for="item in sort" :value="item.value" :key="item">{{ item.label }}' +
        '                    </i-option>' +
        '                </i-select>' +
        '            </strong>' +
        '        </div>' +
        '    </div>',
        props: {
            secList: {
                type: Array,
                default: function () {
                    return [];
                }
            },
            postList: {
                type: Array,
                default: function () {
                    return [];
                }
            }
        },
        created: function () {
            this.initCol();
            var that = this;
            bus.$on('show-edit-modal', function (status) {
                that.showModal = true;
                that.showMask = true;
                that.status = status;
            });
            bus.$on('edit-staff', function (data) {
                Object.assign(that.currentModalData, data);
                that.currentModalData.BelongToId = that.getParent(that.secList, that.currentModalData.BelongToId);
            });
            bus.$on('on-selected', function (data) {
                that.userTempArr = data;
                that.cacheUserArr = JSON.parse(JSON.stringify(data))
            })
        },
        data: function () {
            return {
                cacheUserArr: [],
                staffFromList: [
                    {
                        value: '员工资料',
                        label: '员工资料'
                    },
                    {
                        value: '所属公司',
                        label: '所属公司'
                    },

                ],
                socialSecurityType: '',
                socialSecurityArr: [
                    {
                        value: 'OwnSocialInsurance',
                        label: '个人'
                    },
                    {
                        value: 'CompanySocialInsurance',
                        label: '公司'
                    }
                ],
                socialSecurityNum: 0,
                saveLoading: false,
                status: '',
                showModal: false,
                showMask: false,
                mapRequiredModalData: ['Name', 'Phone', 'StaffTypeValue',
                    'BelongToId', 'isManage', 'Salary',
                    'PerformanceSalary', 'OwnProvidentFund', 'CompanyProvidentFund',
                    'CompanySocialInsurance', 'ParentalAllowance', 'OwnSocialInsurance'],
                currentModalData: JSON.parse(JSON.stringify(staffModel)),
                tempArr: [],
                //添加新员工
                addNewStaffModal: false,
                //修改账户密码
                modifyaccountpassword: false,
                //忘记密码
                wangjimima: false,
                //绑定手机
                bindmobile: false,

                //绑定微信
                bindwechat: false,
                //添加新员工内容

                fromModal: '',

                //批量修改信息
                alterInfoModal: false,
                disabled: true,
                /*批量修改信息内容*/
                userTempArr: [],
                //移动人员
                moveStaffModal: false,

                //移动人员弹框内容========
                //待转移人员
                staffChecked: false,
                /*转移至*/
                transferTo: '',
                socialSecurityCol: [],
                //连同组员移动
                moveRadio: '',


                /*默认排序*/
                sort: [
                    {
                        label: '实习',
                        value: 1
                    },
                    {
                        label: '试用期',
                        value: 2
                    }
                ],
                defaultSort: '',

                staffTypes: [
                    {
                        label: '实习',
                        value: 1
                    },
                    {
                        label: '试用期',
                        value: 2
                    },
                    {
                        label: '正式',
                        value: 3
                    },
                    {
                        label: '离职',
                        value: 4
                    }
                ],

                userStateOps: [
                    {
                        label: '不启用',
                        value: 0
                    },
                    {
                        label: '启用',
                        value: 1
                    }
                ],

                sexOps: [
                    {
                        label: '男',
                        value: 1
                    },
                    {
                        label: '女',
                        value: 2
                    }
                ]

            }
        },
        methods: {
            initCol: function () {
                this.socialSecurityCol = [
                    {
                        type: 'selection',
                        width: 58,
                        align: 'center'
                    },
                    {
                        title: '姓名',
                        width: 140,
                        align: 'center',
                        key: 'Name'
                    },
                    {
                        title: '社保（个人）',
                        width: 120,
                        align: 'center',
                        key: 'OwnSocialInsurance'
                    },
                    {
                        title: '社保（公司）',
                        width: 110,
                        align: 'center',
                        key: 'CompanySocialInsurance'
                    }
                ]
            },
            exportData: function () {
                bus.$emit('export-data');
            },
            initUserData: function () {
            },
            handleNewStaff: function () {
                this.showEditStaff();
            },
            showEditStaff: function () {
                this.showModal = true;
                this.showMask = true;
            },
            hideEditStaff: function () {
                this.showModal = false;
                this.showMask = false;
                this.status = '';
                this.currentModalData = JSON.parse(JSON.stringify(staffModel));
            },
            handleSaveStaffData: function () {
                var that = this;
                if (this.validateModalData()) {
                    this.currentModalData.CompanyId = window.localStorage.companyId;
                    // format BelongToId
                    var BelongToId = this.currentModalData.BelongToId;
                    this.currentModalData.BelongToId = BelongToId[BelongToId.length - 1];
                    this.saveLoading = true;
                    api.editStaff(this.currentModalData)
                        .done(function (res) {
                            if (res.IsSuccess) {
                                that.$Message.success('保存成功');
                                that.$emit('save-staff-success', res.ResultObject, that.status);
                                that.hideEditStaff();
                            } else {
                                that.$Message.error(res.ErrMsg);
                            }
                        })
                        .fail(function () {
                            that.$Message.error('保存错误');
                        })
                        .always(function () {
                            that.saveLoading = false;
                        })
                } else {
                    this.$Message.error('请填写必填项');
                }
            },
            validateModalData: function () {
                for (var key in this.currentModalData) {
                    if (this.mapRequiredModalData.indexOf(key) !== -1 && this.currentModalData[key] === '') {
                        return false;
                    }
                }
                return true;
            },
            getParent: function (data, currentVal) {

                var getParent = function (data, currentVal) {
                    var res = {
                        data: [],
                        flag: false
                    };
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].value === currentVal) {
                            res.flag = true;
                            res.data.unshift(data[i].value);
                            break;
                        } else if (data[i].hasOwnProperty('children')) {
                            var nextRes = getParent(data[i].children, currentVal);
                            if (nextRes.flag) {
                                res.flag = true;
                                res.data = res.data.concat(nextRes.data);
                                res.data.unshift(data[i].value);
                                break;
                            }
                        }
                    }

                    return res;
                }

                return getParent(data, currentVal).data;
            },
            handleSave: function () {
                if (this.disabled) {
                    var that = this
                    var postArr = []
                    this.cacheUserArr.forEach(function (t, number) {
                        if (t.OwnSocialInsurance !== that.userTempArr[number].OwnSocialInsurance
                            || t.CompanySocialInsurance !== that.userTempArr[number].CompanySocialInsurance) postArr.push(that.userTempArr[number])
                    })
                    api.PostSaveStaffSocialSecurity(postArr)
                        .done(function (res) {
                            if (res.IsSuccess) {
                                that.$emit('on-social-security', res.ResultObject)
                                that.$Message.success('保存成功')
                                that.handleCancel()
                            } else {
                                that.$Message.error(res.ErrMsg)
                            }
                        })
                        .fail(function () {
                            that.$Message.error('保存失败')
                        })
                } else {
                    this.$Message.error('请将数据修改完之后再保存')
                }
            },
            handleCancel: function () {
                this.userTempArr = []
                this.cacheUserArr = []
            },
            handleSelectRow: function (selection) {
                this.tempArr = selection;
            },
            handleSetSafe: function () {
                var that = this
                if (!this.disabled) {
                    if (this.socialSecurityType === 'OwnSocialInsurance') {
                        if (this.tempArr.length !== 0) {
                            this.userTempArr.forEach(function (item) {
                                that.tempArr.forEach(function (t) {
                                    if (item.CompanyId === t.CompanyId) {
                                        item.OwnSocialInsurance = that.socialSecurityNum
                                    }
                                })
                            })
                            this.socialSecurityNum = 0
                        } else {
                            this.$Message.error('未选择需要修改人员')
                        }
                    } else if (this.socialSecurityType === 'CompanySocialInsurance') {
                        if (this.tempArr.length !== 0) {
                            this.userTempArr.forEach(function (item) {
                                that.tempArr.forEach(function (t) {
                                    if (item.CompanyId === t.CompanyId) {
                                        item.CompanySocialInsurance = that.socialSecurityNum
                                    }
                                })
                            })
                            this.socialSecurityNum = 0
                        } else {
                            this.$Message.error('未选择需要修改人员')
                        }
                    } else {
                        this.$Message.error('未选择需要修改保险类型')
                    }
                    this.disabled = !this.disabled;
                } else {
                    this.disabled = !this.disabled;
                }
            }
            // search: function () {
            //   $.get(function (data) {
            //     bus.$emit(data);//通过 bus 发布事件.
            //   });
            // }
        }
    };
    return StaffModal
})
